package com.wty.learnsping.controller;


import com.wty.learnsping.Entity.Person;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ValidateController {



    @RequestMapping("/validate")
    public String validate(@Validated Person person, BindingResult result){
        if(result.hasErrors()){
            System.out.println(result.getAllErrors());
            return "error";
        }
        return person.getName()+person.getAge();
    }
}
